package com.example.springsecuritydemo2.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.springsecuritydemo2.domain.SysMenu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper extends BaseMapper<SysMenu> {
    /**
     * 根据用户ID查询权限列表
     * @param id 用户ID
     * @return 权限标识列表
     */
    @Select({
            "SELECT t1.perm ",
            "FROM sys_menu t1 ",
            "INNER JOIN sys_role_menu t2 ON t2.menu_id = t1.id ",
            "INNER JOIN sys_role t3 ON t3.id = t2.role_id ",
            "INNER JOIN sys_user_role t4 ON t4.role_id = t3.id ",
            "INNER JOIN sys_user t5 ON t5.id = t4.user_id ",
            "WHERE t5.id = #{id}"
    })
    List<String> selectPermsByUserId(Long id);
}

